package com.free.mysql.model;

import java.util.List;

/**
 * 索引
 * 
 * @author liuhuan
 * 
 */
public class Idx {

	private String name;

	private String type;

	private List<Column> colList;
	
	private String idxName;
	
	private String connector="And";
	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	
	public List<Column> getColList() {
		return colList;
	}

	public void setColList(List<Column> colList) {
		this.colList = colList;
	}

	public String getIdxName() {
		Column col=null;
		String str="";
		for(int i=0,len=colList.size();i<len;i++){
			col=colList.get(i);
			if(i!=0){
				str+=(connector+col.getColumnFirstUppder());
			}else{
				str+=col.getColumnFirstUppder();
			}
		}
		idxName=str;
		return idxName;
	}

	public void setIdxName(String idxName) {
		this.idxName = idxName;
	}

	@Override
	public String toString() {
		StringBuilder sb=new StringBuilder(name+"     "+type+"   colList ");
		for(int i=0,len=colList.size();i<len;i++){
			sb.append(colList.get(i).getDb_column()+",");
		}
		return sb.toString();
	}
	
}
